﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace LabMS.Web.Equipment.Valuables
{
    public partial class valuablesborrow : Base.BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            strPagePrivilege.Add("GZSBLY");//必须写在ispostback外
            strPageUserType.Add("mana");
            TextBox10.Attributes.Add("onclick", "c.showMoreDay = false;c.show(this);");

            if (!IsPostBack)
            {
                Bind();
                TextBox1.Attributes.Add("readOnly", "-1");
                TextBox2.Attributes.Add("readOnly", "-1");
                TextBox10.Attributes.Add("readOnly", "-1");
                TextBox3.Attributes.Add("readOnly", "-1");
            }
        }

        public void Bind()
        {
            TextBox10.Text = DateTime.Now.Date.ToShortDateString();
        }

        protected void lbBorrow_Click(object sender, EventArgs e)
        {
            Model.Recipients mrecipients = new LabMS.Model.Recipients();
            ExtendBLL.Recipients ebrecipients = new ExtendBLL.Recipients();

            mrecipients.BorrowedState = TextBox6.Text.Trim();
            mrecipients.ReturnState = TextBox7.Text.Trim();
            mrecipients.Comment = TextBox8.Text.Trim();

            DateTime tempTime = new DateTime();
            if (DateTime.TryParse(TextBox10.Text.Trim(), out tempTime))
            {
                mrecipients.EncodedTime = tempTime;
            }
            mrecipients.MRecipients = TextBox3.Text.Trim();
            mrecipients.Name = TextBox2.Text.Trim();
            mrecipients.Numbers = TextBox1.Text.Trim();
            mrecipients.OperatDate = DateTime.Now;
            mrecipients.Operator = TextBox9.Text.Trim();
            mrecipients.Type = "guizhongyiqi";
            try
            {
                ebrecipients.ExtendAdd(mrecipients);
                LabMS.Common.JShelper.JSAlertAndRedirect(Page, "AddSuccess", "领用成功!", "valuablesborrow.aspx");
            }
            catch (Exception ex)
            {
                Err.Text = ex.Message.ToString();
            }
        }
    }
}
